﻿IF EXISTS (select NULL from sys.default_constraints where name = N'DF_Localizations_ControlId')
BEGIN ALTER TABLE [dbo].[Localizations] DROP CONSTRAINT [DF_Localizations_ControlId] END

IF EXISTS (select NULL from sys.default_constraints where name = N'DF_Localizations_PageId')
BEGIN ALTER TABLE [dbo].[Localizations] DROP CONSTRAINT [DF_Localizations_PageId] END

ALTER TABLE [dbo].[Localizations] 
 ALTER COLUMN ResourceId varchar(255) not null
	
ALTER TABLE [dbo].[Localizations] 
 ALTER COLUMN ResourceSet varchar(255) not null

IF NOT EXISTS (SELECT name FROM sysindexes WHERE name = 'IX_Localizations_Unique')
BEGIN
CREATE UNIQUE NONCLUSTERED INDEX [IX_Localizations_Unique] ON [dbo].[Localizations] 
(
	[ResourceId] ASC,
	[LocaleId] ASC,
	[ResourceSet] ASC
)WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
END


IF NOT EXISTS(SELECT NULL FROM Medianamik_Role WHERE RoleId = '35b2b704-6f40-4f73-9d31-fd8bc9600ea2')  BEGIN INSERT INTO medianamik_Role (RoleId, Name) VALUES('35b2b704-6f40-4f73-9d31-fd8bc9600ea2', 'DeleteNodeBranch') END